package innerclassdemo5;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 阿宾
 * Date: 2025-03-13
 * Time: 08:32
 */
public class Car {
    private String name;
    int age;
    String color;
    //外部类访问内部类，需要创建对象
    public void show(){
        System.out.println(name);
        //只有创建对象才可以
        Engine c = new Engine();
        System.out.println(c.engineName);
    }

    class Engine{
        String engineName;
        int engineAge;

        //内部类可以直接访问外部类成员，包括私有
        public void show(){
            System.out.println(engineAge);
            System.out.println(name);
        }
    }
}
